<template>
    <div id="home_server">
        <div class="container clearflx">
            <div class="clearflx" style="line-height: 26px;">
                <ul class="clearflx top_leftTab">
                    <li
                            class="top_leftTablists"
                            :class="{'top_leftTablists-active':tab==0}"
                            @click="tab=0"
                    >最新加入
                    </li>
                    <li
                            class="top_leftTablists"
                            :class="{'top_leftTablists-active':tab==1}"
                            @click="tab=1"
                    >推荐服务商
                    </li>
                    <li
                            class="top_leftTablists"
                            :class="{'top_leftTablists-active':tab==2}"
                            @click="tab=2"
                    >热门服务商
                    </li>
                </ul>
                <div style class="tabmore">
                    <span>>>展会服务频道</span>
                </div>
            </div>
            <div class="top_left">
                <div class="top_banner">
                    <swiper :options="swiperOption">
                        <swiper-slide v-for="(slide, index) in serverbanner" :key="index">
                            <img :src="slide" alt style="width:100%;display:block;"/>
                        </swiper-slide>
                        <!-- <div class="swiper-pagination" slot="pagination"></div> -->
                    </swiper>
                    <div class="swiper-Btn-next server_nextBtn"></div>
                    <div class="swiper-Btn-prev server_prevBtn"></div>
                </div>
            </div>
            <div class="top_right">
                <form action method class="search_bottom clearflx">
                    <input type="text" placeholder="请输入关键词" class="search_text"/>
                    <input type="submit" value="搜服务" class="search_btn"/>
                </form>
                <div class="clearflx" style="margin-top: 10px;margin-left: 47px;">
                    <span class="top_rightTab">会议组织</span>
                    <span class="top_rightTab">宾馆酒店</span>
                    <span class="top_rightTab">营销策划</span>
                    <span class="top_rightTab">兼职服务</span>
                    <span class="top_rightTab">招商代理</span>
                    <span class="top_rightTab">展品运输</span>
                    <p class="top_rightTab_more">更多</p>
                </div>
            </div>
        </div>
        <div class="container">
            <ul class="clearflx list">
                <li v-for="(item,index) in imgs" :key="index" class="lists" @mouseenter="lists=index"
                    @mouseleave="lists=-1">
                    <img :src="item.url" alt class="imgs"/>
                    <div class="mode" v-show="lists==index">
                        <span class="list_title">{{item.title}}</span>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
    import {getCompanyNewest,getCompaniesRecommend} from "../../api/home";

    export default {
        data() {
            return {
                swiperOption: {
                    //   pagination: {
                    //     el: '.swiper-pagination'
                    //   },
                    slidesPerView: 5,
                    // 底部间距
                    spaceBetween: 10,
                    slidesPerGroup: 5,
                    loop: true,
                    autoplay: true,
                    loopFillGroupWithBlank: true,
                    navigation: {
                        nextEl: ".server_nextBtn",
                        prevEl: ".server_prevBtn"
                    }
                },
                serverbanner: [
                    "../../assets/home_infoBanner1.png",
                    "../../assets/home_infoBanner2.png",
                    "../../assets/home_infoBanner3.png",
                    "../../assets/home_infoBanner4.png",
                    "../../assets/home_infoBanner5.png"
                ],
                tab: 0,
                imgs: [
                    {url: "../../assets/home/exhibition_server.png", title: "展具租凭"},
                    {url: "../../assets/home/exhibition_angecy.png", title: "招商代理"},
                    {url: "../../assets/home/exhibition_circum.png", title: "展馆周边"},
                    {url: "../../assets/home/exhibition_set.png", title: "设计搭建"},
                    {
                        url: "../../assets/home/exhibition_translate.png",
                        title: "翻译服务"
                    },
                    {url: "../../assets/home/exhibition_adverts.png", title: "广告服务"}
                ],
                // 下面的图片鼠标移入切换
                lists: -1,
            };
        },
        mounted() {
            /**
             * 展会服务 - 最新加入
             */
            getCompanyNewest().then(res => {
                //this.serverbanner = res.data.data;
                console.log(res.data)
            })
            /**
             * 展会服务 - 推荐服务商
             */
            getCompaniesRecommend().then(res => {
                //this.serverbanner = res.data.data;
                console.log(res.data)
            })
        }
    };
</script>
<style lang="scss" scoped>
    .top_leftTab {
        margin-left: 20px;
        float: left;

        .top_leftTablists {
            float: left;
            margin-right: 40px;
            padding: 0 4px;
            cursor: pointer;
        }

        .top_leftTablists:hover {
            color: #fff;
            background-color: #c81622;
        }

        .top_leftTablists-active {
            color: #fff;
            background-color: #c81622;
        }
    }

    .tabmore {
        float: right;
        color: #c81622;
        cursor: pointer;
    }

    .top_left {
        width: 960px;
        float: left;

        .top_banner {
            width: 100%;
            height: 160px;
            position: relative;

            .swiper-container {
                width: 880px;
                height: 100%;
                //   padding: 0px 20px;
                box-sizing: border-box;
            }

            .swiper-slide {
                text-align: center;
                font-size: 18px;
                background: #fff;
                /* Center slide text vertically */
                display: -webkit-box;
                display: -ms-flexbox;
                display: -webkit-flex;
                display: flex;
                -webkit-box-pack: center;
                -ms-flex-pack: center;
                -webkit-justify-content: center;
                justify-content: center;
                -webkit-box-align: center;
                -ms-flex-align: center;
                -webkit-align-items: center;
                align-items: center;
            }

            .swiper-Btn-next,
            .swiper-Btn-prev {
                position: absolute;
                z-index: 10;
                width: 24px;
                height: 50px;
                text-align: center;
                //   line-height: 30px;
                //   font-size: 24px;
                top: 50%;
                margin-top: -25px;
                cursor: pointer;
                background-size: 100%;
                background-repeat: no-repeat;
            }

            .swiper-Btn-prev {
                left: 0;
                background-image: url("../../assets/banner_prev.png");
            }

            .swiper-Btn-next {
                right: 0;
                background-image: url("../../assets/banner_next.png");
            }
        }
    }

    .top_right {
        width: 240px;
        float: right;
        margin-top: 26px;

        .search_bottom {
            display: block;
            padding-left: 28px;

            .search_text {
                width: 130px;
                height: 10px;
                line-height: 10px;
                font-size: 12px;
                padding: 10px;
                border: 1px solid #c81622;
                float: left;
            }

            .search_btn {
                float: left;
                width: 60px;
                height: 32px;
                line-height: 32px;
                font-size: 16px;
                color: #fff;
                background-color: #c81622;
                border: none;
            }
        }

        .top_rightTab:nth-of-type(n) {
            float: left;
            display: block;
            padding: 0 5px 5px;
            font-size: 14px;
            cursor: pointer;
        }

        .top_rightTab:hover {
            color: #c81622;
        }

        .top_rightTab:nth-of-type(2n) {
            padding: 0 5px 5px;
        }

        .top_rightTab:nth-of-type(3n) {
            padding: 0 0px 5px 5px;
        }

        .top_rightTab_more {
            text-align: right;
            color: #c81622;
            font-size: 14px;
            cursor: pointer;
        }
    }

    .list {
        width: 100%;

        .lists {
            width: 398px;
            height: 200px;
            float: left;
            margin: 1px;
            overflow: hidden;
            position: relative;
            cursor: pointer;

            .mode {
                width: 100%;
                height: 100%;
                position: absolute;
                top: 0;
                left: 0;
                background-color: rgba(0, 0, 0, 0.5);
                display: flex;
                align-items: center;
                justify-content: space-around;

                .list_title {
                    display: block;
                    width: 76px;
                    height: 76px;
                    border-radius: 50%;
                    background-color: #c81622;
                    color: #fff;
                    line-height: 76px;
                }
            }
        }
    }
</style>